// 使用接口模拟在线支付
{
  interface PayInterface {
    handle(price: number): void
  }
  class AliPay implements PayInterface {
    public handle(price: number): void {
      console.log(`支付宝支付${price}元`);

    }
  }

  class WePay implements PayInterface {
    public handle(price: number): void {
      console.log(`微信支付${price}元`);
    }
  }

  // new AliPay().handle(213)
  // new WePay().handle(456)

  function pay(type: string, price: number) {
    let pay: PayInterface
    switch (type) {
      case 'AliPay':
        pay = new AliPay()
        break
      case 'WePay':
        pay = new WePay()
        break
    }
    pay.handle(price)
  }
}